<?
/**
 * 애드페이 (AD-Pay for Gnuboard4)
 *
 * Copyright (c) 2010 Choi Jae-Young <www.miwit.com>
 *
 * 저작권 안내
 * - 저작권자는 이 프로그램을 사용하므로서 발생하는 모든 문제에 대하여 책임을 지지 않습니다. 
 * - 이 프로그램을 어떠한 형태로든 재배포 및 공개하는 것을 허락하지 않습니다.
 * - 이 저작권 표시사항을 저작권자를 제외한 그 누구도 수정할 수 없습니다.
 */

if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가

$order = sql_fetch("select * from $pb[order_table] where or_id = '$or_id' and mb_id = '$member[mb_id]'");
if (!$order)
    alert("자료가 없습니다.");

$product = sql_fetch("select * from $pb[product_table] where pr_id = '$order[pr_id]'");

$edate = $order[or_edate];
if ($edate < $g4[time_ymd]) $edate = "";
?>


<link rel="stylesheet" href="style.css" type="text/css"/>
<style type="text/css">
#pb .tdb { height:25px; text-align:left; padding-left:10px; }
#pb .tdb a:hover { text-decoration:underline; }
#pb .paging { text-align:center; margin:20px 0 20px 0; }
#pb .none { text-align:center; height:100px; }
</style>

<script type="text/javascript" src="<?=$g4[path]?>/js/jquery.js"></script>
<script type="text/javascript" src="<?=$g4[path]?>/js/jquery-ui.js"></script>
<script type="text/javascript" src="<?=$g4[path]?>/js/board.js"></script>
<script type="text/javascript">
function pb_get_info()
{
    $.get("get_product_info.php?pr_id=<?=$order[pr_id]?>&or_edate=<?=$edate?>", function (result) {
        result = result.split('|');
        $("#or_sdate").text(result[0]);
        $("#or_edate").text(result[1]);
        $("#or_cash").text(result[2]);
        $("#or_point").text(result[3]);
    });
}

function adpay_renew()
{
    <? if ($pb[cf_payment_type] == 'cash') { ?>
    if (parseInt(<?=$mw_cash[mb_cash]?>) < parseInt($("#or_cash").text().replace(/,/g, ''))) {
        alert("<?=$mw_cash[cf_cash_name]?> 부족합니다.");
        return;
    }
    <? } else if ($pb[cf_payment_type] == 'point') { ?>
    if (parseInt(<?=$member[mb_point]?>) < parseInt($("#or_point").text().replace(/,/g, ''))) {
        alert("포인트가 부족합니다.");
        return;
    }
    <? } ?>

    if (!confirm("연장 하시겠습니까?")) {
        return;
    }
    var url = "order_renew.php?or_id=<?=$or_id?>&or_sdate=" + $("#or_sdate").text() + "&or_edate=" + $("#or_edate").text();
    location.href = url;
}

$(document).ready(function() {
    pb_get_info();
});
</script>

<div id="pb">

<h3>▶ <?=$pb[cf_name]?> 수정 </h3>

<? if ($is_admin == "super") { ?>
<div style="text-align:right; padding:0 0 10px 0;">
    <a href="javascript:win_open('adm-config.php','adm','width=1000,height=600,scrollbars=yes');">√ 관리자</a>
</div>
<? } ?>

<form name="fwrite" method="post" action="order_update.php" enctype="multipart/form-data">
<input type="hidden" name="or_id" value="<?=$or_id?>">
<input type="hidden" name="page" value="<?=$page?>">

<table class="content" width="100%" border="1" cellspacing="0" cellpadding="0" bordercolor="#cccccc">
<colgroup width="150"/>
<colgroup width=""/>
<tr>
    <td class="tdh"> <div>배너</div> </td>
    <td class="tdb">
        <?=$product[pr_name]?>
    </td>
</tr>
<tr>
    <td class="tdh"> <div>승인</div> </td>
    <td class="tdb">
        <? if ($order[or_app]) echo "승인완료"; else "승인대기"; ?>
    </td>
</tr>
<tr>
    <td class="tdh"> <div>노출기간</div> </td>
    <td class="tdb">
        <?=$order[or_sdate]?> ~ <?=$order[or_edate]?>
    </td>
</tr>
<tr>
    <td class="tdh"> <div><?=$mw_cash[cf_cash_name]?></div> </td>
    <td class="tdb">
        <?=number_format($order[or_cash])?> <?=$mw_cash[cf_cash_unit]?>
    </td>
</tr>
<tr>
    <td class="tdh"> <div>사이트 이름</div> </td>
    <td class="tdb">
        <input type="text" name="or_site" size="50" required itemname="사이트 이름" value="<?=$order[or_site]?>" class="ed">
    </td>
</tr>
<tr>
    <td class="tdh"> <div>사이트 설명</div> </td>
    <td class="tdb">
        <input type="text" name="or_info" size="50" required itemname="사이트 설명" value="<?=$order[or_info]?>" class="ed">
    </td>
</tr>
<tr>
    <td class="tdh"> <div>사이트 주소</div> </td>
    <td class="tdb">
        <input type="text" name="or_url" size="50" required itemname="사이트 주소" value="<?=set_http($order[or_url])?>" class="ed">
    </td>
</tr>
<? if ($product[pr_type] == "i") {?>
<tr>
    <td class="tdh"> <div>배너크기</div> </td>
    <td class="tdb">
        <?=$product[pr_width]?> px × <?=$product[pr_height]?> px 
    </td>
</tr>
<tr>
    <td class="tdh"> <div>배너</div> </td>
    <td class="tdb" style="padding:10px;">
        <div style="padding:10px;">
            <?
            $file_path = "$pb[banner_path]/".urlencode($order[or_file]);
            $size = @getImageSize($file_path);
            ?>
            <?=mw_pay_banner_view($order[or_file], "", $product[pr_width], $product[pr_height],
                " name='target_resize_image[]' onclick='image_window(this, $size[0], $size[1]);'")?>
        </div>
        <input type="file" name="or_file" size="40" itemname="배너" class="ed">
    </td>
</tr>
<? } ?>
<tr>
    <td class="tdh"> <div>등록일시</div> </td>
    <td class="tdb">
        <?=$order[or_datetime]?>
    </td>
</tr>
</table>

<table class="content" width="100%" border="1" cellspacing="0" cellpadding="0" bordercolor="#cccccc">
<colgroup width="150"/>
<colgroup width=""/>
<tr>
    <td class="tdh"> <div>연장가능 날짜</div> </td>
    <td class="tdb">
        <span id="or_sdate"></span> ~
        <span id="or_edate"></span>
    </td>
</tr>
<? if ($pb[cf_payment_type] == 'cash') { ?>
<tr>
    <td class="tdh"> <div><?=$mw_cash[cf_cash_name]?></div> </td>
    <td class="tdb">
        <span id="or_cash"></span>
        <input type="button" value="연장하기" class="btn1" onclick="adpay_renew()" style="margin:0 0 0 20px;">
    </td>
</tr>
<? } else if ($pb[cf_payment_type] == 'point') { ?>
<tr>
    <td class="tdh"> <div>포인트</div> </td>
    <td class="tdb">
        <span id="or_point"></span>
        <input type="button" value="연장하기" class="btn1" onclick="adpay_renew()" style="margin:0 0 0 20px;">
    </td>
</tr>
<? } ?>
</table>

<p align="center" style="margin-top:30px;">
    <input type="submit" value="확     인" class="btn1">
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <input type="button" value="목     록" class="btn1" onclick="location.href='order.php?page=<?=$page?>'">
</p>

</form>

<script type="text/javascript">
$(document).ready (function() {
    resizeBoardImage(500);
});
</script>


